//
//  PictureScrollView.m
//  UI06_UIScrollView
//
//  Created by Scott on 16/5/10.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "PictureScrollView.h"

@implementation PictureScrollView

#pragma mark - override Init
- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self config];
    }
    
    return self;
}


#pragma mark -
- (void)config {
    
    // 指示条
    self.showsHorizontalScrollIndicator = NO;
    self.pagingEnabled = YES;
    
    // 缩放范围
    self.minimumZoomScale = 0.5;
    self.maximumZoomScale = 2;
}
- (void)addPictures:(NSArray<UIImage *> *)pictures {
    
    // 根据图片的数量设置contentSize.
    self.contentSize = CGSizeMake(CGRectGetWidth(self.bounds) * pictures.count, CGRectGetHeight(self.bounds));
    
    
    // 添加图片
    for (int i = 0; i < pictures.count; i++) {
        
        UIImageView *imageView = [[UIImageView alloc] initWithImage:pictures[i]];
        
        imageView.frame = CGRectMake(CGRectGetWidth(self.bounds) * i, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds));
        
        [self addSubview:imageView];
        [imageView release];
        
        
    }
    
    
    
    
}

@end
